(function (angular) {
	'use strict';
	angular.module("fs.logger", ['angular-logger', 'fs.storage'])
		.provider("loggerFactory", ['logEnhancerProvider', function (logEnhancerProvider) {
			var provider = this;
			provider.LEVEL = {
				TRACE: 4,
				DEBUG: 3,
				INFO: 2,
				WARN: 1,
				ERROR: 0,
				OFF: -1
			};
			provider.setPrefixPattern = function () {
				logEnhancerProvider.prefixPattern = '[%s - %s - %s]: ';
			};
			provider.setDatetimePattern = function () {
				logEnhancerProvider.datetimePattern = 'hh:mm:ss';
			};
			provider.setLogLevels = function (logLevels) {
				logEnhancerProvider.logLevels = logLevels;
			};
			this.$get = ['$log', function ($log) {
				return {
					LEVEL: provider.LEVEL,
					getLogger: function (instance) {
						return instance ? $log.getInstance(instance) : $log.getInstance('global')
					},
					setLevel: function (level, instance) {
						(instance && instance !== '*') ? ($log.logLevels[instance] = level) : ($log.logLevels['*'] = level);
					}
				};
			}];
		}]).

		config(['loggerFactoryProvider', function (loggerFactoryProvider) {
			loggerFactoryProvider.setPrefixPattern('[%s - %s - %s]: ');
			loggerFactoryProvider.setDatetimePattern('hh:mm:ss');
			loggerFactoryProvider.setLogLevels({
				'*': loggerFactoryProvider.LEVEL.DEBUG
			});
		}]).

		run(['loggerFactory', function (loggerFactory) {
			loggerFactory.getLogger();
		}]);
})(angular);